//    Copyright (C) Kherty.  All rights reserved.
using System;
using OpenLS.Core.Serialization;
using OpenLS.Vml.Serialization;

namespace OpenLS.Vml
{
    public class Stroke: ShapeElement
    {
        internal const string xmlName = "stroke";
        internal override void ReadXmlCore(ReadContext context)
        {
            using (var c = context.Read(VmlConstants.VmlNamespace + xmlName))
            {
                Id = c.GetOptionalString("id");
                On  = c.GetOptionalString("on");
                Weight = c.GetOptionalString("weight");
                Color = c.GetOptionalString("color");
                Opacity = c.GetOptionalString("opacity");
                LineStyle = c.GetOptionalEnum<StrokeLineStyle>("linestyle");
                MiterLimit = c.GetOptionalDouble("miterlimit");
                JoinStyle = c.GetOptionalEnum<StrokeJoinStyle>("joinstyle");
                EndCap = c.GetOptionalEnum<StrokeEndCap>("endcap");
                DashStyle = c.GetOptionalString("dashstyle");
                FillType = c.GetOptionalEnum<FillType>("filltype");
                Source = c.GetOptionalString("src");
                ImageAspect = c.GetOptionalEnum<ImageAspect>("imageaspect");
                ImageSize = c.GetOptionalString("imagesize");
                ImageAlignShape = c.GetOptionalString("imagealignshape");
                Color2 = c.GetOptionalString("color2");
                StartArrow = c.GetOptionalEnum<StrokeArrowType>("startarrow");
                StartArrowWidth = c.GetOptionalEnum<StrokeArrowWidth>("startarrowwidth");
                StartArrowLength = c.GetOptionalEnum<StrokeArrowLength>("startarrowlength");
                EndArrow = c.GetOptionalEnum<StrokeArrowType>("endarrow");
                EndArrowWidth = c.GetOptionalEnum<StrokeArrowWidth>("endarrowwidth");
                EndArrowLength = c.GetOptionalEnum<StrokeArrowLength>("endarrowlength");

                HRef  = c.GetOptionalString(VmlConstants.OfficeNamespace + "href");
                AltHRef = c.GetOptionalString(VmlConstants.OfficeNamespace + "althref");
                Title = c.GetOptionalString(VmlConstants.OfficeNamespace + "title");
                ForceDash = c.GetOptionalString(VmlConstants.OfficeNamespace + "forcedash");

                string rId = c.GetOptionalString(OfficeConstants.RelationshipNamespace + "id");
                if (rId != null)
                    throw new NotImplementedException();
                InsetPen = c.GetOptionalString("insetpen");

                string RelId = c.GetOptionalString(VmlConstants.OfficeNamespace + "relid");
                if (RelId != null)
                    throw new NotImplementedException();

                Left = c.ReadOptionalElementAs<StrokeChild>("left");
                Top = c.ReadOptionalElementAs<StrokeChild>("top");
                Right = c.ReadOptionalElementAs<StrokeChild>("right");
                Bottom = c.ReadOptionalElementAs<StrokeChild>("bottom");
                Column = c.ReadOptionalElementAs<StrokeChild>("column");
            }
        }

        internal override void WriteXmlCore(WriteContext context)
        {
            using (WriteContext c = context.Write(VmlConstants.VmlNamespace + xmlName))
            {
                c.SetOptionalString("id", Id);
                c.SetOptionalString("on", On);
                c.SetOptionalString("weight", Weight);
                c.SetOptionalString("color", Color);
                c.SetOptionalString("opacity", Opacity);
                c.SetOptionalEnum("linestyle", LineStyle);
                c.SetOptionalDouble("miterlimit", MiterLimit);
                c.SetOptionalEnum("joinstyle", JoinStyle);
                c.SetOptionalEnum("endcap", EndCap);
                c.SetOptionalString("dashstyle", DashStyle);
                c.SetOptionalEnum("filltype", FillType);
                c.SetOptionalString("src", Source);
                c.SetOptionalEnum("imageaspect", ImageAspect);
                c.SetOptionalString("imagesize", ImageSize);
                c.SetOptionalString("imagealignshape", ImageAlignShape);
                c.SetOptionalString("color2", Color2);
                c.SetOptionalEnum("startarrow", StartArrow);
                c.SetOptionalEnum("startarrowwidth", StartArrowWidth);
                c.SetOptionalEnum("startarrowlength", StartArrowLength);
                c.SetOptionalEnum("endarrow", EndArrow);
                c.SetOptionalEnum("endarrowwidth", EndArrowWidth);
                c.SetOptionalEnum("endarrowlength", EndArrowLength);

                c.SetOptionalString(VmlConstants.OfficeNamespace + "href", HRef);
                c.SetOptionalString(VmlConstants.OfficeNamespace + "althref", AltHRef);
                c.SetOptionalString(VmlConstants.OfficeNamespace + "title", Title);
                c.SetOptionalString(VmlConstants.OfficeNamespace + "forcedash", ForceDash);

                //\\rId
                c.SetOptionalString("insetpen", InsetPen);

                //\\string RelId = c.GetOptionalString("relid", VmlConstants.OfficeNamespaceUri);
                
                c.WriteOptionalElementAs(Left, "left");
                c.WriteOptionalElementAs(Top, "top");
                c.WriteOptionalElementAs(Right, "right");
                c.WriteOptionalElementAs(Bottom, "bottom");
                c.WriteOptionalElementAs(Column, "column");
            }
        }

        private string _id;

        public string Id
        {
            get { return _id; }
            set { _id = value; }
        }
	

        private StrokeChild _left;

        public StrokeChild Left
        {
            get { return _left; }
            set { _left = value; }
        }
        private StrokeChild _top;

        public StrokeChild Top
        {
            get { return _top; }
            set { _top = value; }
        }
        private StrokeChild _right;

        public StrokeChild Right
        {
            get { return _right; }
            set { _right = value; }
        }
        private StrokeChild _bottom;

        public StrokeChild Bottom
        {
            get { return _bottom; }
            set { _bottom = value; }
        }
        private StrokeChild _column;

        public StrokeChild Column
        {
            get { return _column; }
            set { _column = value; }
        }
        private string _on;

        public string On
        {
            get { return _on; }
            set { _on = value; }
        }
        private string _weight;

        public string Weight
        {
            get { return _weight; }
            set { _weight = value; }
        }
        private string _color;

        public string Color
        {
            get { return _color; }
            set { _color = value; }
        }
        private string _opacity;

        public string Opacity
        {
            get { return _opacity; }
            set { _opacity = value; }
        }
        private StrokeLineStyle? _linestyle;

        public StrokeLineStyle? LineStyle
        {
            get { return _linestyle; }
            set { _linestyle = value; }
        }
        private double? _miterlimit;

        public double? MiterLimit
        {
            get { return _miterlimit; }
            set { _miterlimit = value; }
        }
        private StrokeJoinStyle? _joinstyle;

        public StrokeJoinStyle? JoinStyle
        {
            get { return _joinstyle; }
            set { _joinstyle = value; }
        }
        private StrokeEndCap? _endcap;

        public StrokeEndCap? EndCap
        {
            get { return _endcap; }
            set { _endcap = value; }
        }
        private string _dashstyle;

        public string DashStyle
        {
            get { return _dashstyle; }
            set { _dashstyle = value; }
        }
        private FillType? _filltype;

        public FillType? FillType
        {
            get { return _filltype; }
            set { _filltype = value; }
        }
        private string _src;

        public string Source
        {
            get { return _src; }
            set { _src = value; }
        }
        private ImageAspect? _imageaspect;

        public ImageAspect? ImageAspect
        {
            get { return _imageaspect; }
            set { _imageaspect = value; }
        }
        private string _imagesize;

        public string ImageSize
        {
            get { return _imagesize; }
            set { _imagesize = value; }
        }
        private string _imagealignshape;

        public string ImageAlignShape
        {
            get { return _imagealignshape; }
            set { _imagealignshape = value; }
        }
        private string _color2;

        public string Color2
        {
            get { return _color2; }
            set { _color2 = value; }
        }
        private StrokeArrowType? _startarrow;

        public StrokeArrowType? StartArrow
        {
            get { return _startarrow; }
            set { _startarrow = value; }
        }
        private StrokeArrowWidth? _startarrowwidth;

        public StrokeArrowWidth? StartArrowWidth
        {
            get { return _startarrowwidth; }
            set { _startarrowwidth = value; }
        }
        private StrokeArrowLength? _startarrowlength;

        public StrokeArrowLength? StartArrowLength
        {
            get { return _startarrowlength; }
            set { _startarrowlength = value; }
        }
        private StrokeArrowType? _endarrow;

        public StrokeArrowType? EndArrow
        {
            get { return _endarrow; }
            set { _endarrow = value; }
        }
        private StrokeArrowWidth? _endarrowwidth;

        public StrokeArrowWidth? EndArrowWidth
        {
            get { return _endarrowwidth; }
            set { _endarrowwidth = value; }
        }
        private StrokeArrowLength? _endarrowlength;

        public StrokeArrowLength? EndArrowLength
        {
            get { return _endarrowlength; }
            set { _endarrowlength = value; }
        }
        private string _href;

        public string HRef
        {
            get { return _href; }
            set { _href = value; }
        }
        private string _althref;

        public string AltHRef
        {
            get { return _althref; }
            set { _althref = value; }
        }
        private string _title;

        public string Title
        {
            get { return _title; }
            set { _title = value; }
        }
        private string _forcedash;

        public string ForceDash
        {
            get { return _forcedash; }
            set { _forcedash = value; }
        }
        private string _rid;

        public string Rid
        {
            get { return _rid; }
            set { _rid = value; }
        }
        private string _insetpen;

        public string InsetPen
        {
            get { return _insetpen; }
            set { _insetpen = value; }
        }
    }
}
